import React from 'react'
import {Redirect, Route, Switch} from 'react-router-dom'
import LazyRoute from './../../LazyRoute'

import Total from 'bundle-loader?lazy!./Total'
import User from 'bundle-loader?lazy!./User'
import Order from 'bundle-loader?lazy!./Order'

const RouteConfig = [
    {
        path: '/datas/total',
        component: Total,
    },
    {
        path: '/datas/user',
        component: User,
    },
    {
        path: '/datas/order',
        component: Order,
    }
];

class Datas extends React.Component {

    componentWillUpdate(newProps) {
    }

    render() {
        return <div>
            <Switch>
                {RouteConfig.map(function (route, index) {
                    return <LazyRoute key={index} path={route.path} component={route.component}/>
                })}
                <Redirect to="/datas/total"/>
            </Switch>
        </div>
    }
}

export default Datas

// Datas LazyRoute#path 优化参考: Users/index.js